package com.jxdinfo.hussar.example.mes.md.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
import com.jxdinfo.hussar.example.mes.md.service.IMdErpenumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jxdinfo.hussar.example.common.annotation.Log;
import com.jxdinfo.hussar.example.common.core.controller.BaseController;
import com.jxdinfo.hussar.example.common.core.domain.AjaxResult;
import com.jxdinfo.hussar.example.mes.md.domain.MdErpenum;
import com.jxdinfo.hussar.example.common.core.page.TableDataInfo;
import com.jxdinfo.hussar.example.common.enums.BusinessType;
import com.jxdinfo.hussar.example.common.utils.poi.ExcelUtil;

/**
 * ERP枚举Controller
 *
 * @author 常宝坤
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/md/erpenum")
public class MdErpenumController extends BaseController
{
    @Autowired
    private IMdErpenumService mdErpenumService;

    /**
     * 查询ERP枚举列表
     */
//    @PreAuthorize("@ss.hasPermi('md:erpenum:list')")
    @GetMapping("/list")
    public TableDataInfo list(MdErpenum mdErpenum)
    {
        startPage();
        List<MdErpenum> list = mdErpenumService.selectMdErpenumList(mdErpenum);
        return getDataTable(list);
    }

    /**
     * 导出ERP枚举列表
     */
//    @PreAuthorize("@ss.hasPermi('md:erpenum:export')")
    @Log(title = "ERP枚举", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdErpenum mdErpenum)
    {
        List<MdErpenum> list = mdErpenumService.selectMdErpenumList(mdErpenum);
        ExcelUtil<MdErpenum> util = new ExcelUtil<MdErpenum>(MdErpenum.class);
        util.exportExcel(response, list, "ERP枚举数据");
    }

    /**
     * 获取ERP枚举详细信息
     */
//    @PreAuthorize("@ss.hasPermi('md:erpenum:query')")
    @GetMapping(value = "/get/{enumId}")
    public AjaxResult getInfo(@PathVariable("enumId") Long enumId)
    {
        return AjaxResult.success(mdErpenumService.selectMdErpenumByEnumId(enumId));
    }

    /**
     * 新增ERP枚举
     */
//    @PreAuthorize("@ss.hasPermi('md:erpenum:add')")
    @Log(title = "ERP枚举", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody MdErpenum mdErpenum)
    {
        return toAjax(mdErpenumService.insertMdErpenum(mdErpenum));
    }

    /**
     * 修改ERP枚举
     */
//    @PreAuthorize("@ss.hasPermi('md:erpenum:edit')")
    @Log(title = "ERP枚举", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody MdErpenum mdErpenum)
    {
        return toAjax(mdErpenumService.updateMdErpenum(mdErpenum));
    }

    /**
     * 删除ERP枚举
     */
//    @PreAuthorize("@ss.hasPermi('md:erpenum:remove')")
    @Log(title = "ERP枚举", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{enumIds}")
    public AjaxResult remove(@PathVariable Long[] enumIds)
    {
        return toAjax(mdErpenumService.deleteMdErpenumByEnumIds(enumIds));
    }
}
